﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace LIMS.Web
{
    public partial class AdmTestItemManange : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                AspNetPager1.RecordCount = BLL.ProjectManager.SearchProject(null).Count;
                rpProject.DataSource = BLL.CommonPager<Model.Projects>.GetTSourceByPager(BLL.ProjectManager.SearchProject(null), AspNetPager1.PageSize, 1);
                rpProject.DataBind();
            }
        }

        protected void btnFindByTitle_Click(object sender, EventArgs e)
        {
            rpProject.DataSource = BLL.CommonPager<Model.Projects>.GetTSourceByPager(BLL.ProjectManager.SearchProject(txtProTitle.Text.Trim()), AspNetPager1.PageSize, 1);
            rpProject.DataBind();
        }

        protected void btnAddPro_Click(object sender, EventArgs e)
        {
            Response.Redirect("AdmTestStuManage.aspx");
        }
        /// <summary>
        /// 根据教师ID获取其姓名
        /// </summary>
        /// <param name="teaID"></param>
        /// <returns></returns>
        protected String bindTeaNameByID(object teaID)
        {
            return (teaID != null && string.IsNullOrWhiteSpace(teaID.ToString())) ? BLL.TeacherManager.GetNameByID(teaID.ToString()) : "";
        }

        /// <summary>
        /// 字符串截取
        /// </summary>
        /// <param name="strInput">需要截断的字符串</param>
        /// <param name="nLength">截断字符串的长度</param>
        /// <returns></returns>
        protected string SubString(string strInput, int nLength)
        {
            if (strInput.Length <= nLength)
            {
                return strInput;
            }
            return strInput.Substring(0, nLength) + "…";
        }

        protected void AspNetPager1_PageChanged(object sender, EventArgs e)
        {
            rpProject.DataSource = BLL.CommonPager<Model.Projects>.GetTSourceByPager(BLL.ProjectManager.SearchProject(null), 
                                                                                            AspNetPager1.PageSize, AspNetPager1.CurrentPageIndex);
            rpProject.DataBind();
        }

        protected void rpProject_OnItemDataBound(object sender, RepeaterItemEventArgs e)
        {

            //字符串截取
            //string strInput = e.Cells[7].Text;
            //e.Row.Cells[7].Text = SubString(strInput, 18);
            //e.Row.Cells[7].ToolTip = strInput;
        }
    }
}